package com.controller;

import com.constants.Constants;
import com.entity.AllTask;
import com.tools.BaseUntil;
import com.until.TaskManag;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

import java.net.URL;
import java.util.ResourceBundle;

public class TaskViewController extends BaseUntil implements Initializable {
    public TaskViewController() {
        //初始化时保存当前Controller实例
        Constants.controllers.put(this.getClass().getSimpleName(), this);
    }

    private AllTask ditileTask = MainController.ditileTask;

    @FXML
    private Label queryTask;
    @FXML
    private TextField id;
    @FXML
    private TextField title;
    @FXML
    private TextField info;
    @FXML
    private TextField tasktype;
    @FXML
    private TextField countpotato;
    @FXML
    private TextField countsleep;
    @FXML
    private TextField nowtype;
    @FXML
    private TextField msg;
    @FXML
    private TextField maketime;
    @FXML
    private TextField finishtime;

    public void clossWindow() {
        Stage stage = (Stage) queryTask.getScene().getWindow();
        stage.close();
    }

    @Override
    public void initialize(URL location, ResourceBundle resources) {
        showDitle();
    }

    public void showDitle() {
        try {
            id.setText(ditileTask.getId());
            title.setText(ditileTask.getTitle());
            info.setText(ditileTask.getInfo());
            tasktype.setText(ditileTask.getTasktype());
            countpotato.setText(ditileTask.getCountpotato());
            countsleep.setText(ditileTask.getCountsleep());
            nowtype.setText(ditileTask.getNowtype());
            msg.setText(ditileTask.getMsg());
            maketime.setText(ditileTask.getMaketime());
            finishtime.setText(ditileTask.getFinishtime());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
